/* dmultica.c
 *	Client user program of distributed Coach Attendant in a train simulation
 *	
 *	Runs multiple Coach Attendant clients
 */
 
#include "syscall.h"

const int NUMBER_OF_COACHATTENDANTS = 3; /*How many Coach Attendant on the Train*/

int main(int argc, char **argv)
{
	int i;
	for(i=0;i<NUMBER_OF_COACHATTENDANTS; i++)
	{
		Exec("../test/dca", 11);
	}

	Exit(0);
}


int myexp ( int count ) {
  int i, val=1;
  for (i=0; i<count; i++ ) {
    val = val * 10;
  }
  return val;
}

void itoa( char arr[], int size, int val ) {
  int i, max, dig, subval, loc;
  for (i=0; i<size; i++ ) {
    arr[i] = '\0';
  }

  for ( i=1; i<=10; i++ ) {
    if (( val / myexp(i) ) == 0 ) {
      max = i-1;
      break;
    }
  }

  subval = 0;
  loc = 0;
  for ( i=max; i>=0; i-- ) {
    dig = 48 + ((val-subval) / myexp(i));
    subval += (dig-48) * myexp(i);
    arr[loc] = dig;
    loc++;
  }

  return;
}
